package cn.terminus.data.customer.contractselldefyloaninfo.impl;

import cn.terminus.common.customer.bean.contractselldefyloaninfo.dto.*;
import cn.terminus.data.customer.contractselldefyloaninfo.dao.ContractSellDefyLoanInfoDao;
import cn.terminus.data.customer.contractselldefyloaninfo.mapper.ContractSellDefyLoanInfoMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 贷款违约(ContractSellDefyLoanInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-07-21 11:18:14
 */
@Repository
public class ContractSellDefyLoanInfoDaoImpl implements ContractSellDefyLoanInfoDao {
    @Resource
    private ContractSellDefyLoanInfoMapper contractSellDefyLoanInfoMapper;

    @Override
    public Integer add(ContractSellDefyLoanInfoNewDto dto) {
        return contractSellDefyLoanInfoMapper.add(dto);
    }

    @Override
    public Integer update(ContractSellDefyLoanInfoEditDto dto) {
        return contractSellDefyLoanInfoMapper.update(dto);
    }

    @Override
    public List<ContractSellDefyLoanInfoResultDto> gets(ContractSellDefyLoanInfoGetsDto dto) {
        return contractSellDefyLoanInfoMapper.gets(dto);
    }

    @Override
    public List<ContractSellDefyLoanInfoResultDto> query(ContractSellDefyLoanInfoQueryDto dto) {
        return contractSellDefyLoanInfoMapper.query(dto);
    }

    @Override
    public Integer delete(ContractSellDefyLoanInfoDeleteDto dto) {
        return contractSellDefyLoanInfoMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<ContractSellDefyLoanInfoResultDto> page(ContractSellDefyLoanInfoQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<ContractSellDefyLoanInfoResultDto> result = (Page<ContractSellDefyLoanInfoResultDto>) contractSellDefyLoanInfoMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), ContractSellDefyLoanInfoResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer deleteWithContractId(Long id) {
        return contractSellDefyLoanInfoMapper.deleteWithContractId(id);
    }
}
